﻿using SeriesUtil.Helper;
using SeriesUtil.Provider;
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace SeriesUtil
{
    public partial class SettingsWindow : Form
    {
        public SettingsWindow()
        {
            InitializeComponent();
            // again no idea how to bind Profiles to the Listbox
            this.listBoxProfiles.DataSource = SeriesUtil.Properties.Settings.Default.Profiles;
            this.listBoxProfiles.DisplayMember = "Name";
            this.listBoxProfiles.ValueMember = "Id";
            foreach(var provider in ProviderList.Instance.Provider)
            {
                this.comboBoxWebSource.Items.Add(provider);
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void listBoxProfiles_SelectedIndexChanged(object sender, EventArgs e)
        {
            ParserProfile profile = this.listBoxProfiles.SelectedValue as ParserProfile;
            this.textBoxProfileName.Text = profile.Name;
            this.textBoxInFormat.Text = profile.InFormat;
            this.textBoxOutFormat.Text = profile.OutFormat;
            this.checkBoxProfileAbsolute.Checked = profile.Absolute;
        }
    }
}
